package belf.migrate.engine.job.cdc;

import belf.migrate.api.common.DatabaseIdentifier;
import belf.migrate.api.source.cdc.CDCSource;
import belf.migrate.api.taskconf.JobContext;
import belf.migrate.api.taskconf.TaskConf;
import belf.migrate.plugin.mysql.MySQLCDCSource;
import belf.migrate.plugin.oracle.OracleCDCSource;
import belf.migrate.plugin.sqlserver.SqlServerCDCSource;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CDCSourceCreator {
    public static CDCSource createSource(JobContext jobContext, TaskConf taskConf) {
        switch (taskConf.getSourceConf().getCatalogName()) {
            case DatabaseIdentifier.MYSQL:
                return new MySQLCDCSource(jobContext);
            case DatabaseIdentifier.ORACLE:
                return new OracleCDCSource(jobContext);
            case DatabaseIdentifier.SQLSERVER:
                return new SqlServerCDCSource(jobContext);
            default:
                log.error("Fatal Error!!!No Valid CDCSource Found For {}!!!", taskConf.getSourceConf().getCatalogName());
                return null;
        }
    }
}
